Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Multi-colour console output from [Chalk](https://github.com/sindresorhus/chalk#styles) with added awesome.
Multi-colour console output from Chalk with added awesome.
by @shakyshane & @AydinHassan
##Install
npm install tfunk
##Usage
Syntax rules:
{
<color>
:
YOUR STRING
}
Example
{blue:This is a blue line}
}
is optional
{blue:This is a blue line
<- Perfectly valid
##Usage
var tFunk = require("tfunk");
console.log( tfunk("{cyan:tFunk terminal colours") )
// => tFunk terminal colours
Or get a custom compiler with a set prefix:
var compiler = require("tfunk").Compiler({
prefix: "[{magenta:tFunk}]"
});
console.log( compiler.compile("tFunk is awesome") );
console.log( compiler.compile("don't you think?") );
// => [tFunk] tFunk is awesome
// => [tFunk] don't you think?
Define your own syntax
You can define your own methods, they receive the string section as the first parameter & have access to the compiler
through this.compile()
keyword.
var compiler = require("tfunk").Compiler({
"warn": function(string) {
return this.compile("{red:WARNING:" + string);
}
});
Now you can use warn
anywhere you like.
console.log( compiler.compile("{warn: Could not file your config file...") );
// => WARNING: Could not file your config file...
##Examples
Here are some comparisons to chalk, to help you understand how to use tFunk.
###Single Colours
// chalk
console.log( chalk.red("This has a single colour") );
// tFunk
console.log( tFunk("{red:This has a single colour") );
###Single Colour mid string
// chalk
console.log( "This has a single colour " + chalk.cyan("that begins mid-string") );
// tFunck
console.log( tFunk("This has a single colour {cyan:that begins mid-string") );
###Single Colour with end point
// chalk
console.log( chalk.red("This has a single colour with ") + "an endpoint");
// tFunk
console.log( tFunk("{red:This has a single colour with }an endpoint") );
###Two Colours
// chalk
console.log( chalk.green("This has ") + chalk.cyan("two colours") );
// tFunk
console.log( tFunk("{green:This has {cyan:two colours") );
###Nested Colours
// chalk
console.log( chalk.green("This has a colour " + chalk.cyan("nested inside") + " another colour") );
//tFunk
console.log( tFunk("{green:This has a colour {cyan:nested inside} another colour") );
###Multiple Nested
// chalk
console.log( chalk.blue("Multiple " + chalk.cyan("NESTED") + " styles in " + chalk.red("the same string") + " with an ending") );
// tFunk
console.log( tFunk("{blue:Multiple {cyan:NESTED} styles in {red:the same string} with an ending") );
###Multi line
var multiline = require("multiline");
var string = multiline(function () {/*
{cyan:This is a multi-line coloured string
With a single {yellow:yellow} word in the center of a line
Pretty cool huh?
*/});
console.log( tFunk(string) );
##TODO
"{white.bgRed: White text, red BG"
}
will be lostFAQs
Multi-colour console output from chalk with added awesome
The npm package tfunk receives a total of 149,956 weekly downloads. As such, tfunk popularity was classified as popular.
We found that tfunk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.